/* 
 * file:funciones.js
 * author:mvalentin
 */

function dialogAlert(txtTitle, txtContent){
    var thisdialog = new dijit.Dialog({ title: txtTitle, content: txtContent });
    dojo.body().appendChild(thisdialog.domNode);
    thisdialog.startup();
    thisdialog.show();
}

function onlyInteger(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla ==  8) return true;
    if (tecla ==  9) return true;
    if (tecla == 13) return true;
    if (tecla == 37) return true;
    if (tecla == 39) return true;
    patron =/\d/;
    te = String.fromCharCode(tecla);
    return patron.test(te);
}

function soloLetrasYnumeros(e){
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla ==  8) return true;
    if (tecla ==  9) return true;
    if (tecla == 13) return true;
    if (tecla == 37) return true;
    if (tecla == 39) return true;
    if (tecla == 32) return true;
    patron =/[<>¿?"':;_#*&%!¡$]/;
    te = String.fromCharCode(tecla);
    return !patron.test(te);
}

function ponerMayusculas(nombre){
      nombre.value=nombre.value.toUpperCase();
}

function fnGrabarGeneral(){
    fnGrabarDatosVehiculo(1);
   
}

function fnDescargarGeneral(){
    fnGrabarDatosVehiculo(2);
}

function imprimir(nlipa_codigo){
    var liqu = document.getElementById(nlipa_codigo).value ;
    var width  = screen.width-50;
    var height = screen.height-100;
    var left   = 10;
    var top    = 10;
    var params = 'width='+width+',height='+height;
    params += ',top='+top+',left='+left;
    params += ',directories=no';
    params += ',location=no';
    params += ',menubar=no';
    params += ',resizable=yes';
    params += ',scrollbars=no';
    params += ',status=no';
    params += ',toolbar=no';
    window.open("imprimirmanifiesto.pdf?nlipa_codigo="+liqu,'windowname',params);
}


function confirmDialog(title, question, callbackFn, params ) {

    var errorDialog = new dijit.Dialog({ id: 'queryDialog', title: title });
    var callback = function(mouseEvent) {
        errorDialog.hide();
        errorDialog.destroyRecursive();

        var srcEl = mouseEvent.srcElement? mouseEvent.srcElement : mouseEvent.target; //IE or Firefox
        var rpta = srcEl.id;
        if (rpta.indexOf("yes") !=-1) {
            callbackFn(params);
        }
        
    };
    var questionDiv = dojo.create('div', { innerHTML: question });
    var yesButton = new dijit.form.Button(
        { label: 'Yes', id: 'yes', onClick: callback });
    var noButton = new dijit.form.Button(
        { label: 'No', id: 'no', onClick: callback });

    errorDialog.containerNode.appendChild(questionDiv);
    errorDialog.containerNode.appendChild(yesButton.domNode);
    errorDialog.containerNode.appendChild(noButton.domNode);
    errorDialog.show();
}